/*
 *
 * Copyright 2017-2018. All rights reserved.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.loveprogrammer.eternity.enums;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 武器类型
 *
 * @author eric
 * @version 1.0.0
 */
public enum WeaponTypeEnum {

    SWORD(1, "长剑"),
    WAND(2, "魔杖"),
    DAGGER(3, "匕首"),
    GUN(4, "枪类"),
    HAMMER(5, "锤类"),
    AXE(6, "斧类"),
    STICK(7, "棍类");

    private Integer code;

    private String desc;

    WeaponTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static WeaponTypeEnum getByCode(int code){
        Optional<WeaponTypeEnum> optional =
                Arrays.stream(WeaponTypeEnum.values())
                        .filter(v -> Objects.equals(v.getCode(), code))
                        .findFirst();

        return optional.orElse(WeaponTypeEnum.SWORD);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
